package com.forum.framework.banner.core;

import cn.hutool.core.thread.ThreadUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

import java.util.concurrent.TimeUnit;

/**
 * 项目启动成功后，提供文档相关的地址
 *
 * @author zihan.ouyang
 */
public class BannerApplicationRunner implements ApplicationRunner {
    private static final Logger logger = LoggerFactory.getLogger(BannerApplicationRunner.class);

    @Override
    public void run(ApplicationArguments args) throws Exception {
        ThreadUtil.execute(() -> {
            ThreadUtil.sleep(1, TimeUnit.SECONDS);
            logger.info("\n----------------------------------------------------------\n\t" +
                            "项目启动成功！\n\t" + "接口文档: \t{} \n\t" + "开发文档: \t{} \n\t" +
                            "----------------------------------------------------------",
                    "http://localhost:48080/doc.html", "http://localhost:48080/doc.html");
        });
    }
}
